<template>
  <div id="app">
    <!-- 登录页面不显示导航栏 -->
    <div v-if="!isLoginPage" class="app-container">
      <!-- 左侧导航栏 -->
      <div class="sidebar">
        <h2>舆情分析系统</h2>
        <div class="sidebar-head-img">
        </div>
        <ul class="sidebar-list">
          <li>
            <router-link to="/spider" class="nav-link">
              <img src="./assets/sidebar/spider.png" alt="数据爬虫图标" class="sidebar-icon">数据爬虫
            </router-link>
          </li>
          <li>
            <router-link to="/dashboard" class="nav-link">
              <img src="./assets/sidebar/sentiment.png" alt="情感分析图标" class="sidebar-icon">情感分析
            </router-link>
          </li>
          <li>
            <router-link to="/generate" class="nav-link">
              <img src="./assets/sidebar/generate.png" alt="内容生成图标" class="sidebar-icon">内容生成
            </router-link>
          </li>
        </ul>
      </div>

      <!-- 右侧内容区域 -->
      <div class="content">
        <router-view />
      </div>
    </div>

    <!-- 登录页面显示 -->
    <router-view v-else />
  </div>
</template>

<script>
export default {
  name: 'App',
  computed: {
    isLoginPage() {
      // 判断当前路由是否为登录页面
      return this.$route.path === '/login';
    },
  },
};
</script>

<style scoped>
#app {

  font-family: Avenir, Helvetica, Arial, sans-serif;
  text-align: center;
  color: #2c3e50;
  margin-top: 0;
  overflow: auto;
}

.app-container {
  display: flex;
  height: 100vh;
  background: #0d1b2a;
  /* 深色背景 */
  color: white;
  overflow: auto;
}

.sidebar {
  width: 200px;
  background: #1b263b;
  /* 侧边栏背景 */
  padding: 1rem;
  box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
}

.sidebar-head-img{
  background-image: url("./assets/headtest.png");
  background-size: cover;
  background-repeat: no-repeat;
  border-radius: 50%;
  margin: 0 auto;
  height: 150px;
  width: 150px;
  margin-top: 20px;
  margin-bottom: 30px;
}

.sidebar-icon {
  width: 35px; /* 设置合适的宽度 */
  height: 35px; /* 设置合适的高度 */
  vertical-align: middle; /* 垂直居中对齐 */
}

.sidebar h2 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  color: #8ecae6;
  /* 标题颜色 */
}

.sidebar ul {
  list-style: none;
  padding: 0;
}

.sidebar li {
  margin-bottom: 1rem;
}

.nav-link {
  color: white;
  text-decoration: none;
  font-size: 1.1rem;
  transition: color 0.3s ease;
}

.nav-link:hover {
  color: #00b4d8;
  /* 鼠标悬停颜色 */
}

.router-link-active {
  color: #00b4d8;
  /* 当前页面链接颜色 */
  font-weight: bold;
}

.content {
  scrollbar-width: thin;
  scrollbar-color: #8ecae6 transparent;
  flex: 1;
  overflow: auto; /* 隐藏整个应用的滚动条 */
}
.content::-webkit-scrollbar {
    width: 8px;
}

.content::-webkit-scrollbar-track {
    background: transparent;
}
.content::-webkit-scrollbar-thumb {
    background-color: #8ecae6;
    border-radius: 4px;
    border: 2px solid transparent;
}
</style>